import request from "@/utils/request";

// 查询特定实验室的预约信息
export function getAppointmentInfoByLabId(laboratoryId) {
  return request({
    url: `/api/reservations/laboratory/${laboratoryId}`,
    method: "get",
  });
}

// 删除实验室
export function deleteLaboratory(laboratoryId) {
  return request({
    url: `/api/laboratories/${laboratoryId}`,
    method: "delete",
  });
}

// 修改实验室基本信息
export function updateLaboratoryInfo(laboratoryId, data) {
  return request({
    url: `/api/laboratories/${laboratoryId}`,
    method: "put",
    data,
  });
}

// 修改实验室启用状态
export function updateLaboratoryStatus(laboratoryId, data) {
  return request({
    url: `/api/laboratories/${laboratoryId}/open?isOpen=${data}`,
    method: "put",
  });
}

// 修改实验室状态
export function updateLaboratoryCapacity(laboratoryId, data) {
  return request({
    url: `/api/laboratories/${laboratoryId}/status?status=${data}`,
    method: "put",
  });
}

// 添加实验室设备
export function addLaboratoryEquipment(data) {
  return request({
    url: `/api/laboratory-equipment`,
    method: "post",
    data,
  });
}

// 修改实验室设备
export function updateLaboratoryEquipment(id,data) {
  return request({
    url: `/api/laboratory-equipment/${id}`,
    method: "put",
    data,
  });
}

// 删除设备
export function deleteEquipment(id) {
  return request({
    url: `/api/laboratory-equipment/${id}`,
    method: "delete",
  });
}

// 获取设备列表
export function getEquipmentList(laboratoryId) {
  return request({
    url: `/api/laboratories/{id}/equipment`,
    method: "get",
  });
}

// 获取某实验室的设备列表
export function getEquipmentListByLabId(laboratoryId) {
  return request({
    url: `/api/laboratory-equipment/laboratory/${laboratoryId}`,
    method: "get",
  });
}

// 获取实验室时间段
// /api/laboratories/{id}/time-slots
export function getLaboratoryTimeSlots(laboratoryId) {
  return request({
    url: `/api/laboratories/${laboratoryId}/time-slots`,
    method: "get",
  });
}

// 修改时间段  （全量更新）
// /api/laboratories/{id}/time-slots
export function updateLaboratoryTimeSlots(laboratoryId, data) {
  return request({
    url: `/api/laboratories/${laboratoryId}/time-slots`,
    method: "put",
    data,
  });
}

// 修改时间段可预约状态 （部分更新）
// /api/laboratory-time-slots/{id}/availability
export function updateLaboratoryTimeSlotAvailability(id, data) {
  return request({
    url: `/api/laboratory-time-slots/${id}/availability`,
    method: "put",
    data,
  });
}

// 获取用户列表
// /api/user-management/users?page=0&size=10&role=STUDENT&department=计算机学院&keyword=张三
export function getUserList(data) {
  return request({
    url: `/api/user-management/users`,
    method: "get",
    params: data,
  });
}

// 更新用户信息
// PUT / api / user - management / users / { id };
export function updateUser(id, data) {
  return request({
    url: `/api/user-management/users/${id}`,
    method: "put",
    data,
  });
}

// 删除用户
// DELETE / api / user - management / users / { id };
export function deleteUser(id) {
  return request({
    url: `/api/user-management/users/${id}`,
    method: "delete",
  });
}

// 创建用户
// POST / api / user - management / users;
export function createUser(data) {
  return request({
    url: `/api/user-management/users`,
    method: "post",
    data,
  });
}

// 更新用户状态（是否可登录）
// PUT /api/user-management/users/{id}/status
export function updateUserStatus(id, data) {
  return request({
    url: `/api/user-management/users/${id}/status`,
    method: "put",
    data,
  });
}


